


class Solution(object):
    def countBinarySubstrings(self, s):
        """
        :type s: str
        :rtype: int
        """
        n = len(s)
        if n == 1:
            return 0
        last = 0
        count = 1
        index = 1
        t = 0
        while index < n:
            if s[index] == s[index - 1]:
                count += 1
                if count <= last:
                    t += 1
            else:
                t += 1
                last = count
                count = 1
            index += 1
        return t


data = Solution()
s = "00110011"
print(data.countBinarySubstrings(s))
